package com.easy.config;

import com.easy.interceptor.LoginInterceptor;
import com.easy.interceptor.PrivateInformationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    //注入拦截器
    @Autowired
    LoginInterceptor loginInt;

    @Autowired
    PrivateInformationInterceptor privateInformationInt;

    /**
     * 配置拦截器  让拦截器生效
     * */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(new LoginInterceptor());
        registry.addInterceptor(loginInt).addPathPatterns("/**").excludePathPatterns("/dologin","/checkToken","/captcha","/img/**");
        registry.addInterceptor(privateInformationInt).addPathPatterns("/member");
    }
}
